import json
import common
import requests
from main import main
from binascii import b2a_base64,a2b_base64
from common.strtools import hex_remove_0x

def send(route,json_content=None,post=True):
    url = f"http://{common.args.ClientUIBackendIP}:{common.args.ClientUIBackendPort}"
    url = f"{url}{route}"
    if post:
        resp = requests.post(url,json=json_content)
    else:
        resp = requests.get(url)
    resp_content = resp.content.decode("utf-8")
    return resp_content

r = send("/sign_in",{
    "account_private_key":"6db48dd553696cd5a217ade6215aaca287f9f0ff24f9e4c2f7c583f9a475d197"
})
print(r)

r = send("/handle_registrations",{
    "address":"0x4CD87fa7fE8960d510ff3F9Dae263d1D70c8a01D",
    "agree":True,
    "attributes":[
        b2a_base64("VIP 用户".encode("utf-8")).decode("utf-8")
    ]
})
print(r)

# import time 

# while True:
#     time.sleep(1)